/**
 * Created by mac on 2018/9/5.
 */
import * as actionTypes from './actionTypes';
import { fromJS } from 'immutable';
import axios from 'axios';

export const searchFocus = () => ({
   type: actionTypes.SEARCH_FOCUS
});


export const searchBlur = () => ({
    type: actionTypes.SEARCH_BLUR
});

export const searchContentOnMouseEnter = () => ({
    type: actionTypes.SEARCH_CONTENTVIEW_MOUSE_ENTER
});

export const searchContentOnMouseLeave = () => ({
    type: actionTypes.SEARCH_CONTENTVIEW_MOUSE_LEAVE
});


export const getSearchContentList = () => {
    return (dispatch) => {
        axios.get('api/searchContentList.json').then((res) => {
            if (res.data) {
                dispatch(getListDta(res.data.data));
            }
        }).catch((e) => {
            console.log('请求错误' + e);
        });
    }
}

const getListDta = (data) => ({
    type: actionTypes.GET_SEARCH_CONTENT_LIST,
    data: fromJS(data)
});